package com.example.mapper.pc;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.dto.pc.*;
import com.example.entity.mysql.MoldAllocationDetail;
import com.example.entity.mysql.Resource;
import com.example.entity.vo.DeviceProductLineListVo;
import com.example.entity.vo.pc.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author LiangPandeng
 * @since 2024-05-19
 */
@DS("mes")
public interface ResourceMapper extends BaseMapper<Resource> {

    List<MouldListVo> mouldList(MouldListDto dto);

    List<ResourceListVo> resourceList(ResourceListDto dto);

    List<ProductLineListVo> productLineList();

    List<ProductLineListVo> productLineGroupList();

    List<ResourceListVo> deviceProductLineList(@Param("dto") ResourceListDto dto, @Param("macList") List<String> macList);

    List<ResourcePlus> getResourcePlusByResourceParentId(GetResourcePlusByResourceParentIdDto dto);

    List<ResourcePlus> getResourcePlus(GetSpecificResourceListDto dto);

    /**
     *
     * @param parentResourceId  父级资源ID
     * @param workCenter    工作中心
     * @return
     */
    List<Integer> getResourceIdByTY(@Param("parentResourceId") Integer parentResourceId, @Param("workCenter") String workCenter);

    List<ResourcePlus> getResourcePlusMould(GetSpecificResourceListDto dto);

    List<ResourcePlus> getResourcePlusByWorkCenterAndDeviceId(@Param("deviceId") String deviceId, @Param("workCenter") String workCenter, @Param("val") String val);

    List<ResourceLoadListVo> deviceLoadStatusList
            (@Param("dto")DeviceLoadStatusDto dto, @Param("macList")List<String> macList);

    List<Resource> selUsingMould();

    @Select("SELECT * from resource where (resourceType= 3 or resourceType = 4) and `status` = '待归还'")
    List<Resource> listMould();

    /**
     * 查找正在运行中的机器
     * @return
     */
    List<Resource> getRuninngMachine(List<String> list);

    Resource selectOneByDeviceId(String deviceId);

    /**
     * 根据设备ID更新库存位置
     * @param moldAllocationDetail
     */
    Integer updateStorageLocation(MoldAllocationDetail moldAllocationDetail);

    void backOnlineResource();

    void resetResourceStatus();

    MouldListVo mouldDetailInfo(MouldListDto dto);

    List<Resource> findIdleMachine();

    List<DeviceProductLineListVo> deviceProductLineList2();

    void backMysqlData();

    void backSQLSERVERData();
}
